package com.example.onlinemusic.controller;

import com.example.onlinemusic.common.R;
import com.example.onlinemusic.model.request.RankListRequest;
import com.example.onlinemusic.service.RankListService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
public class RankListController {

    @Autowired
    RankListService rankListService;

    /**
     * 添加评分
     *
     * @param rankListRequest
     * @return
     */
    @PostMapping("/rankList/add")
    public R AddRank(@RequestBody RankListRequest rankListRequest) {
        return rankListService.addRankList(rankListRequest);
    }

    /**
     * 根据歌单id查询歌单评分（评分=总分/数量）
     *
     * @param songListId
     * @return
     */
    @GetMapping("/rankList")
    public R rankOfSongListId(@RequestParam long songListId) {
        return rankListService.rankOfSongListId(songListId);
    }

    /**
     * 获取根据歌单ID和用户ID获取评分
     * @param consumerId
     * @param songListId
     * @return
     */
    @GetMapping("/rankList/user")
    public R getRankScroe(@RequestParam long consumerId, @RequestParam long songListId) {
        return rankListService.getRankScroe(consumerId,songListId);
    }
}
